﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MementoPattern;

/// <summary>
/// 最终存储属性的类，可以是 Redis 等外部存储
/// </summary>
internal class CareTake
{
    /*    private static War3Memnto War3Memnto = null;
        public static void Save(War3Memnto war3Memnto)
        {
            War3Memnto = war3Memnto;
        }

        public static War3Memnto Get() { return War3Memnto; }*/

    private static Dictionary<string, War3Memnto> dict = new Dictionary<string, War3Memnto>();
    public static void Save(string name, War3Memnto war3Memnto)
    {
        //dict.Add(name, war3Memnto);
        dict[name] = war3Memnto;
    }

    public static War3Memnto Get(string name)
    {
        if (dict.ContainsKey(name))
        {
            return dict[name];
        }
        throw new Exception("wrong name");
    }
}
